#!/usr/bin/env bash
#
# Version 1.1
# - Moved to .ci folder and seperated out `run-repository.sh`
# - Add `$RUNSCRIPTS` env var for running Elasticsearch dependent products

# Default environment variables
export STACK_VERSION="${STACK_VERSION:=8.0.0-SNAPSHOT}"
export TEST_SUITE="${TEST_SUITE:=platinum}"
export PYTHON_VERSION="${PYTHON_VERSION:=3.9}"
export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=urllib3}"

script_path=$(dirname $(realpath -s $0))
source $script_path/functions/imports.sh
set -euo pipefail

echo "--- :elasticsearch: Starting Elasticsearch"
DETACH=true bash $script_path/run-elasticsearch.sh

if [[ -n "$RUNSCRIPTS" ]]; then
  for RUNSCRIPT in ${RUNSCRIPTS//,/ } ; do
    echo -e "\033[1m>>>>> Running run-$RUNSCRIPT.sh >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
    CONTAINER_NAME=${RUNSCRIPT} \
      DETACH=true \
      bash $script_path/run-${RUNSCRIPT}.sh
  done
fi

echo "+++ :python: Client tests"
bash $script_path/run-repository.sh
